//
//  PersonalSettingFeedbackController.m
//  ChatForHot
//
//  Created by wr on 2018/10/17.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PersonalSettingFeedbackController.h"
#import "PersonalSettingFeedbackView.h"
#import "PersonalSettingViewModel.h"

@interface PersonalSettingFeedbackController ()<SettingFeedbackDelegate>

@property (nonatomic, strong) PersonalSettingFeedbackView *HOTCHATfeedbkVIew;
@property (nonatomic, strong) PersonalSettingViewModel *viewModel;
@end

@implementation PersonalSettingFeedbackController

- (void)HOTCHATdidInitialized {
    [super HOTCHATdidInitialized];
    
    self.viewModel = [[PersonalSettingViewModel alloc] init];
}

- (void)HOTCHATInsertSubViews {
    [super HOTCHATInsertSubViews];
    
    self.HOTCHATfeedbkVIew = [[PersonalSettingFeedbackView alloc] init];
    self.HOTCHATfeedbkVIew.delegate = self;
    [self.view addSubview:self.HOTCHATfeedbkVIew];
}

- (void)HOTCHATsetNavigationItemsIsInEditMode:(BOOL)isInEditMode animated:(BOOL)animated {
    [super HOTCHATsetNavigationItemsIsInEditMode:isInEditMode animated:animated];
    
    self.title = NSLocalizedString(@"personS3", nil);
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    [self.HOTCHATfeedbkVIew mas_updateConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    @weakify(self)
    [self.viewModel.requestFeedbackCommand.executionSignals subscribeNext:^(RACSignal *excution) {
        [[excution dematerialize] subscribeNext:^(id x) {
            @strongify(self)
            [self.navigationController popViewControllerAnimated:YES];
        } error:^(NSError *error) {
            
        }];
    }];
}

- (void)HOTCHATFeedback:(NSString *)advice {
    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
    [parameters setValue:[APPINFO defaultManager].accountid forKey:@"accountid"];
    [parameters setValue:@"1" forKey:@"clientType"];
    [parameters setValue:[advice HOTCHATmaxLength:200] forKey:@"content"];
    [self.viewModel.requestFeedbackCommand execute:parameters];
}
@end
